//
//  RCTestWindowController.m
//  Choice
//
//  Created by Rhys Cox on 31/08/2007.
//  Copyright 2007 Rhys Cox. All rights reserved.
//

#import "RCTestWindowController.h"


@implementation RCTestWindowController

- (BOOL)windowShouldClose:(NSWindow *)sender
{
	if([sender isDocumentEdited]){
		NSString *msg = @"By cancelling the test all of your progress so far will be ignored.";
		SEL sel = @selector(sheetClosed:returnCode:contextInfo:);
		NSBeginAlertSheet(@"Cancel the test?",@"OK",@"Cancel",nil,sender,self,sel,NULL,sender,msg,nil);
		return NO;
	}
	else{
		return YES;
	}
}

- (void)sheetClosed:(NSWindow *)sheet returnCode:(int)returnCode contextInfo:(void *)contextInfo
{
	if(returnCode == NSAlertDefaultReturn){
		[(NSWindow *)contextInfo close];
	}
}

@end
